//package com.sky.controller;
//
//import com.sky.mapper.StudentMapper;
//import com.sky.pojo.StudentTest;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.poi.ss.formula.functions.Intercept;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.CachePut;
//import org.springframework.cache.annotation.Cacheable;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//
////@RestController
////@RequestMapping("/student")
////@Api(tags = "测试类")
////@Slf4j
//public class StudentTestController {
//    @Resource
//    StudentMapper studentMapper;
//
//    /**
//     * 把方法返回值放到缓存
//     * @param student
//     * @return
//     */
//    @CachePut(cacheNames = "stu_cache", key = "#result.id")
//    @PostMapping
//    @ApiOperation("新增学生")
//    public StudentTest add(@RequestBody StudentTest student) {
//        log.warn("{}", student);
//        studentMapper.insert(student);
//        return student;
//    }
//
//    /**
//     * 执行前先查询缓存中是否有数据 有就返回缓存数据 没有就查询数据库并放入缓存
//     * @param id
//     * @return
//     */
//    @Cacheable(cacheNames = "stu_cache", key = "#id")
//    @GetMapping("/{id}")
//    @ApiOperation("根据id查询学生")
//    public StudentTest findById(@PathVariable("id") Integer id) {
//        log.warn("{}", id);
//        return studentMapper.selectById(id);
//    }
//    /**
//     * 删除一个缓存
//     */
//    @CacheEvict(cacheNames = "stu_cache", key = "#id")
//    @DeleteMapping("/{id}")
//    @ApiOperation("根据id删除学生")
//    public void deleteById(@PathVariable("id") Integer id) {
//        studentMapper.deleteById(id);
//    }
//    /**
//     * 删除全部缓存
//     */
//    @CacheEvict(cacheNames = "stu_cache", allEntries = true)
//    @DeleteMapping
//    @ApiOperation("删除全部学生")
//
//    public void deleteAll() {
//        studentMapper.deleteByAll();
//    }
//}
